package com.ldn.common.basic.enums.web;

import com.ldn.common.basic.enums.EnumMap;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 客户端跳转类型枚举
 *
 * @author 李大牛家的牛 (scafel@163.com)
 * @product serverless
 * @className JumpTypeEnums
 * @createDate 2025/1/17 - 9:32
 * @description 客户端跳转类型枚举
 **/
@Getter
public enum JumpTypeEnums {

    // 跳转打开图片
    JUMP_OPEN_IMAGE(6, "跳转打开图片"),
    // 跳转打开视频
    JUMP_OPEN_VIDEO(5, "跳转打开视频"),
    // 跳转打开网页
    JUMP_OPEN_WEB_PAGE(4, "跳转打开网页"),
    // 不跳转打开网页
    NOT_JUMP_OPEN_WEB_PAGE(3, "不跳转打开网页"),
    // 不跳转打开视频
    NOT_JUMP_OPEN_VIDEO(2, "不跳转打开视频"),
    // 不跳转打开图片
    NO_JUMP_OPEN_IMAGE(1, "不跳转打开图片"),
    // 不跳转
    NOT_JUMP(0, "不跳转");
    ;

    private static final Map<Integer, JumpTypeEnums> codeToEnumMap = new ConcurrentHashMap<>();
    private static final ArrayList<EnumMap> enumMap = new ArrayList<>();

    static {
        for (JumpTypeEnums type : JumpTypeEnums.values()) {
            codeToEnumMap.put(type.getCode(), type);
            EnumMap map = new EnumMap();
            map.setKey(type.getCode());
            map.setLabel(type.getMessage());
            enumMap.add(map);
        }
    }

    private final int code;
    /**
     * 自定义描述
     **/
    private final String message;

    JumpTypeEnums(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public static JumpTypeEnums getType(int code) {
        JumpTypeEnums type = codeToEnumMap.get(code);
        if (type == null) {
            return JumpTypeEnums.NOT_JUMP;
        }
        return type;
    }

    /**
     * 获取枚举类中所有的枚举值
     * @return Map
     */
    public static ArrayList<EnumMap> getEnumsMap() {
        return enumMap;
    }
}
